<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="cn.company.bean.Culture"%>
<%@page import="cn.company.database.DBUtils"%>
<%@page import="cn.company.bean.Sort"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>网站后台管理系统</title>
<%
	String id = request.getParameter("id");
	String path = request.getContextPath();
	Culture culture = DBUtils.getCultureById(Integer.parseInt(id));
	List<Sort> sorts = DBUtils.getSortsByModuleId(4);
	int sortid = DBUtils.getSortIdBySubSort(Integer.parseInt(id));
%>
<script language="javascript" src="<%=path %>/OurHome/images/jquery.js"></script>
<link href="<%=path %>/OurHome/css/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	function callback(msg){
		 document.getElementById("msg").innerHTML = msg;  
		 document.getElementById("path").value=msg;
	}
	function CreateXmlHttp() { 
		var xmlhttp = false;
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		    try {
			    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		    } catch (e2) {
			    xmlhttp = false;
		    }
		}
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		var data = document.getElementById("sortid").value;   
		if(!xmlhttp) { 
	         alert("创建xmlhttp对象异常！"); 
	         return false; 
	    }   
	    xmlhttp.open("POST",location.href.substring(0, location.href.lastIndexOf('/'))+"/subsortservlet.jsp?data="+data,false); 
		xmlhttp.onreadystatechange = function() {   
			if(xmlhttp.readyState == 4) { 
				if(xmlhttp.status == 200){ 
					var jsons = eval('('+xmlhttp.responseText+')');
					if(jsons.length == 0){
						document.form2.subsortid.options[0] = new Option("==请选择==","");
					}else{
						for(i = 0;i < jsons.length;i++){
							document.form2.subsortid.options[i] = new Option(jsons[i].subsortname,jsons[i].subsortid);
						}
						for(i = 0;i < jsons.length;i++){
							document.form2.subsortid.options[i] = new Option(jsons[i].subsortname,jsons[i].subsortid);
						}
					}
	            }      
	        } 
	    };
	    xmlhttp.send(); 
	}  
</script>
</head>
<body>
	<div id="mainDiv">
		<c:import url="../public/top.jsp" />
		<div id="centerDiv">
			<c:import url="../public/navigation.jsp"></c:import>
			<div id="right"> 
				<div id="current">&nbsp;&nbsp;&nbsp;&nbsp;当前位置: 公司文化管理</div>
				<div id="form">
					<P>&nbsp;</P>
					<fieldset>
						<legend>修改公司文化文章:</legend>
						<form action="<%=path %>/OurHome/uploadAttaches.jsp" method="post" enctype="multipart/form-data" target="uploadIframe">
							添加附件：<input type="file" name="upload"/>
							<input type="submit" value="上传"/><br>
							<span id="msg"></span>
						</form>
						<iframe name="uploadIframe" id="uploadIframe" style="display:none"></iframe>
						<form action="<%=path %>/OurHomeControlServlet" method="post" name="form2" id="form2">
							<input type="hidden" name="action" value="updateculture" />
							<input type="hidden" name="id" id="id" value="<%=id %>" />
							<input type="hidden" name="path" id="path" value="<%=culture.getImagepath() %>"/>
							标题：<input type="text" id="topic" name="topic" value="<%=culture.getTopic() %>"/><br>
							时间：<input type="text" id="time" name="time" value="<%=culture.getTime() %>"/>(格式：2010-08-08)<br>
							分类:
							<select name="sortid" id="sortid" onchange="CreateXmlHttp();">
								<%
									for(int i = 0;i < sorts.size();i++){
								%>
										<option value="<%=sorts.get(i).getId() %>" <%if (sorts.get(i).getId()==sortid){%>selected="selected"<%} %>><%=sorts.get(i).getSortName() %></option>
								<%
									}
								%>
							</select>
							<select name="subsortid" id="subsortid">
								<option value="<%=culture.getSortid() %>" selected="selected"><%=DBUtils.getSubSortNameById(culture.getSortid())%></option>
							</select><br>
							<c:set var="content" value="<%=culture.getContent() %>"></c:set>
							<c:url value="../../jsp/demo2.jsp" var="contextUrl"><c:param name="content" value="${content}" /></c:url>
							内容：<c:import url="${contextUrl}"></c:import>
							图片：<img alt="<%=culture.getTopic() %>" src="<%=path %>/<%=culture.getImagepath() %>" style="width:60px;height:60px;"/><br>
							&nbsp;<input type="submit" value="提交内容" id="submit" name="submit"/>
						</form>
					</fieldset>
					<p>&nbsp;</p>
				</div>
			</div>
		</div>
		<div id="bottomDiv"></div>
	</div>
	<script language="javascript">
		$("#test1").toggle(function(){$("#test").slideDown();},function(){$("#test").slideUp();});
	</script>
</body>
<%!
private String htmlspecialchars(String str) {
	str = str.replaceAll("&", "&amp;");
	str = str.replaceAll("<", "&lt;");
	str = str.replaceAll(">", "&gt;");
	str = str.replaceAll("\"", "&quot;");
	return str;
}
%>
</html>
